package com.kk.permission.utils.floatwindow;

import android.os.Build;
import android.text.TextUtils;
import android.util.Log;

public class RomUtils {
    private static final String TAG = "RomUtils";

    public static double getEmuiVersion() {
        try {
            String systemProperty = getSystemProperty("ro.build.version.emui");
            return Double.parseDouble(systemProperty.substring(systemProperty.indexOf("_") + 1));
        } catch (Exception e) {
            e.printStackTrace();
            return 4.0d;
        }
    }

    public static int getMiuiVersion() {
        String systemProperty = getSystemProperty("ro.miui.ui.version.name");
        if (systemProperty != null) {
            try {
                return Integer.parseInt(systemProperty.substring(1));
            } catch (Exception unused) {
                String str = TAG;
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("get miui version code error, version : ");
                stringBuilder.append(systemProperty);
                Log.e(str, stringBuilder.toString());
            }
        }
        return -1;
    }

    /* JADX WARNING: Removed duplicated region for block: B:26:0x006f A:{SYNTHETIC, Splitter: B:26:0x006f} */
    /* JADX WARNING: Removed duplicated region for block: B:18:0x005e A:{SYNTHETIC, Splitter: B:18:0x005e} */
    public static java.lang.String getSystemProperty(java.lang.String r6) {
        /*
        r0 = 0;
        r1 = java.lang.Runtime.getRuntime();	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r2 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r2.<init>();	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r3 = "getprop ";
        r2.append(r3);	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r2.append(r6);	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r2 = r2.toString();	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r1 = r1.exec(r2);	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r2 = new java.io.BufferedReader;	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r3 = new java.io.InputStreamReader;	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r1 = r1.getInputStream();	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r3.<init>(r1);	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r1 = 1024; // 0x400 float:1.435E-42 double:5.06E-321;
        r2.<init>(r3, r1);	 Catch:{ IOException -> 0x0044, all -> 0x0042 }
        r1 = r2.readLine();	 Catch:{ IOException -> 0x0040 }
        r2.close();	 Catch:{ IOException -> 0x0040 }
        if (r2 == 0) goto L_0x003f;
    L_0x0033:
        r2.close();	 Catch:{ IOException -> 0x0037 }
        goto L_0x003f;
    L_0x0037:
        r6 = move-exception;
        r0 = "RomUtils";
        r2 = "Exception while closing InputStream";
        android.util.Log.e(r0, r2, r6);
    L_0x003f:
        return r1;
    L_0x0040:
        r1 = move-exception;
        goto L_0x0046;
    L_0x0042:
        r6 = move-exception;
        goto L_0x006d;
    L_0x0044:
        r1 = move-exception;
        r2 = r0;
    L_0x0046:
        r3 = "RomUtils";
        r4 = new java.lang.StringBuilder;	 Catch:{ all -> 0x006b }
        r4.<init>();	 Catch:{ all -> 0x006b }
        r5 = "Unable to read sysprop ";
        r4.append(r5);	 Catch:{ all -> 0x006b }
        r4.append(r6);	 Catch:{ all -> 0x006b }
        r6 = r4.toString();	 Catch:{ all -> 0x006b }
        android.util.Log.e(r3, r6, r1);	 Catch:{ all -> 0x006b }
        if (r2 == 0) goto L_0x006a;
    L_0x005e:
        r2.close();	 Catch:{ IOException -> 0x0062 }
        goto L_0x006a;
    L_0x0062:
        r6 = move-exception;
        r1 = "RomUtils";
        r2 = "Exception while closing InputStream";
        android.util.Log.e(r1, r2, r6);
    L_0x006a:
        return r0;
    L_0x006b:
        r6 = move-exception;
        r0 = r2;
    L_0x006d:
        if (r0 == 0) goto L_0x007b;
    L_0x006f:
        r0.close();	 Catch:{ IOException -> 0x0073 }
        goto L_0x007b;
    L_0x0073:
        r0 = move-exception;
        r1 = "RomUtils";
        r2 = "Exception while closing InputStream";
        android.util.Log.e(r1, r2, r0);
    L_0x007b:
        throw r6;
        */
        //throw new UnsupportedOperationException("Method not decompiled: com.cootek.permission.utils.floatwindow.RomUtils.getSystemProperty(java.lang.String):java.lang.String");
        return "";
    }

    public static boolean checkIsHuaweiRom() {
        return Build.MANUFACTURER.contains("HUAWEI");
    }

    public static boolean checkIsMiuiRom() {
        return TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name")) ^ true;
    }

    public static boolean checkIsMeizuRom() {
        String systemProperty = getSystemProperty("ro.build.display.id");
        if (TextUtils.isEmpty(systemProperty)) {
            return false;
        }
        if (systemProperty.contains("flyme") || systemProperty.toLowerCase().contains("flyme")) {
            return true;
        }
        return false;
    }

    public static boolean checkIs360Rom() {
        return Build.MANUFACTURER.contains("QiKU") || Build.MANUFACTURER.contains("360");
    }

    public static boolean checkIsOppoRom() {
        return Build.MANUFACTURER.contains("OPPO") || Build.MANUFACTURER.contains("oppo");
    }

    public static boolean checkIsVivoRom() {
        return Build.MANUFACTURER.contains("VIVO") || Build.MANUFACTURER.contains("vivo");
    }
}
